﻿using System;

namespace Lesson8_练习题
{
    //写一个用于数学计算的静态类
    //提供计算 圆面积、圆周长、矩形面积、矩形周长、对一个数取绝对值 等方法
    static class Cal
    {
        static float PI = 3.14f;

        /// <summary>
        /// 计算圆面积
        /// </summary>
        /// <param name="r">圆半径</param>
        /// <returns></returns>
        static public double CalCircleArea(float r)
        {
            return PI * r * r;
        } 
        /// <summary>
        /// 计算圆周长
        /// </summary>
        /// <param name="r">圆半径</param>
        /// <returns></returns>
        static public double CalCirclePeri(float r)
        {
            return 2 * PI * r;
        }
        /// <summary>
        /// 矩形面积
        /// </summary>
        /// <param name="length">矩形长</param>
        /// <param name="width">矩形宽</param>
        /// <returns></returns>
        static public float CalRectArea(float length, float width)
        {
            return length * width;
        }
        /// <summary>
        /// 矩形周长
        /// </summary>
        /// <param name="length">矩形长</param>
        /// <param name="width">矩形宽</param>
        /// <returns></returns>
        static public float CalRectPeri(float length, float width)
        {
            return 2 * (length + width);
        }
        /// <summary>
        /// 取绝对值
        /// </summary>
        /// <param name="value">取绝对值的对象</param>
        /// <returns></returns>
        static public double GetAbsoluteValue(float value)
        {
            if (value < 0)
            {
                return -value;
            }
            else
            {
                return value;
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Cal.CalCircleArea(11.4f));
            Console.WriteLine(Cal.CalCirclePeri(11.4f));
            Console.WriteLine(Cal.CalRectArea(2.2f, 2.2f));
            Console.WriteLine(Cal.CalRectPeri(2.2f, 2.2f));
            Console.WriteLine(Cal.GetAbsoluteValue(-10086));
            Console.WriteLine(Cal.GetAbsoluteValue(10086));
        }
    }
}